package com.example.javaspringweb.service;

import com.example.javaspringweb.dao.DataMapper;
import com.example.javaspringweb.entity.DataDemo;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("DataService")
public class DataServiceImpl implements DataService{
//    @Autowired是按类型查找Bean，@Resource是按名查找
    @Resource
    private DataMapper dataMapper;

    @Transactional(readOnly = true) // 数据库读取方式 只读
    @Override
    public List<DataDemo> getAll() {
        return dataMapper.findAll();
    }

    // 查
    @Transactional(readOnly = true) // 数据库读取方式 只读
    @Override
    public List<DataDemo> getRegion(String region) {
        return dataMapper.findRegion(region);
    }
}
